<template>
	<view class="order_push" style="padding-bottom: 200rpx;">
		<u-navbar bgColor="#fff" :placeholder="true" :fixed="true" @leftClick="$back" title="我的派单" titleStyle="{'color': '#000'}">
			
		</u-navbar>
		<view class="order_push_top">
			<view class="baibox">
				
				<view class="baili" v-if="form.task_type==0" @click="currentType=0,showFee = true">
					<view class="txt">
						费用标准
					</view>
					<view class="cenbox">
						<view class="centxt">
							<text v-if="!form.price">请选择</text>
							<text class="tp1">
								{{form.price}} &nbsp;
							</text>
							<text class="tp2">
								{{form.price?"币/"+form.word_count:""}}
							</text>
						</view>
					</view>
					<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
				</view>

				<view v-if="form.task_type==0" class="baili" @click="currentType=1,showFont = true">
					<view class="txt">
						字数要求
					</view>
					<view class="cenbox">
						<view class="centxt">
							<text v-if="!form.start_shooting">请选择</text>
							<text  v-else>
								{{form.start_shooting}}{{form.word_count}}
							</text>
						</view>
					</view>
					<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
				</view>
				
				<view v-if="form.task_type==1" class="baili" @click="showFont = true">
					<view class="txt">
						字数要求
					</view>
					<view class="cenbox">
						<view class="centxt">
							<text v-if="!form.start_shooting">请选择</text>
							<text  v-else>
								{{form.start_shooting}}{{form.word_count}}
							</text>
						</view>
					</view>
					<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
				</view>
				
				
				<!-- <view class="baili" v-if="form.task_type==0">
					<view class="left">
						<view class="title">
							字数要求
						</view>
						<input @input="onInput" type="number" class="put" placeholder="请输入字数" maxlength="5" v-model="form.start_shooting">
					</view>
					<view class="desText">{{form.word_count?form.word_count:array[index]}}</view>
				</view> -->
				
				<view class="baili" v-if="form.task_type==1" @click="form.money='',show_money = true">
					<view class="txt">
						订单总价
					</view>
					<view class="cenbox">
						<view class="centxt">
							<text v-if="form.money==0">请输入</text>
							<text v-else >
								{{parseInt(form.money)}} 
							</text>
						</view>
					</view>
					<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
				</view>
				
			
				
				<view class="baili" >
					<!-- <picker class="baiput"  @change="leiChange" :value="lei" :range="leiList" range-key="tit">
						<view class="title">
							类型选择
						</view>
						
						{{leiList ? leiList[lei].tit : '不限'}}
					</picker> -->
					<view class="baiput" @tap="showSort=true">
						<view class="title">
							类型选择
						</view>
						
						{{leiList ? leiList[lei].tit : '不限'}}
					</view>
					<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
				</view>
				
				
				<view class="baili"  @click="showTime=true">
					<view class="txt">
						截稿时间
					</view>
					<view class="cenbox">
						<!-- {{form.end_time_param?form.end_time_param.substring(0,17) : "请选择"}}	 -->
						<block v-if="form.end_time">
							{{years.length ? (years[times[0]] + '年' + month[times[1]] + '月' + date[times[2]] + '日 ' + hour[times[3]] + ':' + minute[times[4]]) : ''}}
						</block>
						<block v-else>请选择</block>
					</view>
					<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
				</view>
			</view>
			
			<view class="baibox">
				<view class="baili">
					<view class="txt">
						制作要求
					</view>
					<view class="cenbox"  @click="$go('/task/list/order_push_desc')">
					
						<text v-if="form.c_desc==''||form.c_desc==null">点击输入</text>
						<text v-else class="c_desc">
							{{form.c_desc}}
						</text>
					</view>
					<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
				</view>
			</view>
			
			<view class="baibox">
				<view class="baili" @tap="showGender= true">
					<view class="txt">
						性别要求
					</view>
					<view class="cenbox" >
						<view>
							<view class="centxt">{{array_sex[form.sex]}}</view>
						</view>
					</view>
					<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
				</view>
				<view class="baili" @tap="showLevel=true">
					<view class="txt">
						等级要求
					</view>
					<view class="cenbox">
						<view>
							<view class="centxt" v-if="form.level">{{level_arr[levels[0]]}}{{level_arr2[levels[1]]}}</view>
							<view class="centxt" v-else>
								不限
							</view>
						</view>
					</view>
					<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
				</view>
			</view>
			
			<view class="baibox">
				<view class="baili">
					<view class="txt">
						优惠券
					</view>
					<!-- <view class="cenbox" @click="quan=true">
						<view class="numtxt" @click="quan = true" v-if="!selCoupItem.id">
							点击选择
						</view>
						<view class="numtxt" @click="quan = true" v-else>
							{{selCoupItem.coupon.title}}
							<text>-{{selCoupItem.coupon.price}}</text>
						</view>
					</view> -->
					<view class="cenbox" @click.stop="quan=true">
						<view class="numtxt" v-if="!couponList.length">
							暂无可用
						</view>
						<view class="numtxt" v-else>
							<text style="color: #45C4B0;">{{couponList.length}}</text>张可用
							<text v-if="selCoupItem && selCoupItem.coupon && selCoupItem.coupon.price">-{{selCoupItem.coupon.price}}</text>
						</view>
					</view>
					<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
				</view>
			</view>
			
			<view class="baibox">
				<view class="baili" style="min-height: 180rpx;display: block;">
					<view class="zhan display-flex just-between" style="padding: 10px 0;">
						作品保密
						
						<!-- #ifndef APP-PLUS -->
						<!-- <u-switch v-model="form.is_primsg" :inactiveValue="0"
							:activeValue="1" inactiveColor="#888EB6" size="20" activeColor="#45C4B0"
							@change="change('is_primsg')"></u-switch> -->
						<!-- #endif -->
						<!-- #ifdef APP-PLUS -->
						<!-- <switch :checked="form.is_primsg == 1" style="transform:scale(0.7)" color="#45C4B0" @change="change('is_primsg')" /> -->
						<!-- #endif -->
						
						<switch :checked="form.is_primsg == 1" style="transform:scale(0.7)" color="#45C4B0" @change="change('is_primsg')" />
					</view>
					
					<view class="bnt" style="padding-bottom: 10px;">
					
						开启后即视为此订单的产出作品仅供付款方（发起用户）所查阅，制作方（接单写手）在完成改订单产出作品后不允许公开该作品。更多相应内容请查看
							<span  @click="$go('/pages/user/abount_dea?id=3')">	《平台约文服务协议及指南》</span>
					
					</view>
					
				</view>
			</view>
			
			<view class="xubox">
				<view class="xutxt">
					派单指南<br>
					1、派单后，该订单将推送给符合筛选条件的写手。请填写详细的制作要求，更详细的要求，更容易找到心仪的写手。<br>
					2、派单后将有受邀写手申请抢单，写手抢单时会填写抢单理由、上传相关例文，如有心仪写手，可选择确认匹配，下单后代表匹配成功，将进入订单流程。<br>
					3、发出的单子将于一天后过期，请及时选择匹配写手。如并无心仪写手，可不选择。<br>
					4、请勿发出违反平台规定的单子，如无意义刷屏单、论文单等。如发现违反规定的订单，平台将下架该订单，如多次发现违规派单行为，该账号的派单功能可能被封禁。<br>
					<!-- 写手匹配下单须知:<br>
					1、成功付款后，订单金额将由平台保管，订单完成后到账写手账户；<br>
					2、争议退单可到"我的”“订单查询"进行订单申诉；<br>
					3、下单后请私信写手沟通细节；<br>
					4、若写手期限内未交付作品，可无条件退单；<br>
					5、发起派单后，订单页不再支持更改；<br>
					6、阅读并同意<text @click.stop="goToOtherxie(3)">《约稿指南和下单规范》</text><br> -->
				</view>
			</view>
			
		</view>
		
		
		<view class="dibox" >
			<view class="zaibox">
				<view class="zaileft">
					<view class="dbox">
						<view class="text">
							订单总价预计
						</view>
						<view class="zaititle">
							 {{ parseInt(form.money)}}币
						</view>
					
					</view>
					<view class="zaitxt">
						订单费用在选择写手时进行支付
					</view>
				</view>
				<view class="que" @click="postApply" :class="{'que2': !form.money || !form.end_time || !form.c_desc}">
					发起派单
				</view>
			</view>
			<view class="xiebox" @click="isRead =( isRead == 2?0:2)" :class="isRead == 1 ? 'shake-horizontal' : ''">
				<label>
					<!-- #ifdef APP-PLUS -->
						<!-- <u-checkbox-group>
							<u-checkbox :checked="isRead" shape="circle" activeColor="#45C4B0"></u-checkbox>
						</u-checkbox-group> -->
						<!-- <checkbox style="transform: scale(0.7);" :checked="isRead" color="#45C4B0" borderColor="#45C4B0"/> -->
					<!-- #endif -->
					<!-- #ifndef APP-PLUS -->
					<!-- <checkbox style="transform: scale(0.7);" :checked="isRead" /> -->
					<!-- #endif -->
					
					<u-checkbox shape="circle" size="14" :checked="isRead" activeColor="#45C4B0" inactiveColor="#999" @change="changeBox"></u-checkbox>
				</label>
				<view class="xietxt">
					<!-- <span  @click="$go('/pages/user/abount_dea?id=3')">	《平台约文服务协议及指南》</span> -->
					请阅读并同意：<text @click.stop="$go('/pages/user/abount_dea?id=3')">《平台约文服务协议及指南》</text>
				</view>
			</view>
		</view>
		
		
		<u-popup :show="show_money" mode="center" @close="show_money=false" @open="open">
			<view class="mask1">
				<view class="jatitle" >
					订单总价
				</view>
				<input type="digit" class="japut" placeholder="请输入价格(币)"
					v-model="form.money">
					
			
				<view class="qubox">
					<view class="quli" @click="show_money=false">
						取消
					</view>
					<view class="que" @click="show_money=false">
						确定
					</view>
				</view>
			</view>
		</u-popup>
		
		<u-popup :show="show_font" mode="center" @close="show_font=false" @open="open">
			<view class="mask1">
				<view class="jatitle" >
					数量
				</view>
				<input type="number" class="japut" placeholder="请输入数量"
					v-model="form.start_shooting">
				<view class="jatitle" >
					字数设置
				</view>
				
				<picker  class="japut" @change="bindPickerChange" :value="index" :range="array">
					{{array[index]}}
				</picker>
				<view class="qubox">
					<view class="quli" @click="show_font=false">
						取消
					</view>
					<view class="que" @click="setting1()">
						确定
					</view>
				</view>
			</view>
		</u-popup>
		
		
		
		
		
		<!-- 优惠券弹框 -->
		<u-popup :show="quan" @close="hidequan">
			<view class="mask111">
				<view class="matop">
					<view class="matxt" @click="quan = false">
						取消
					</view>
					<view class="matitle">
						优惠券
					</view>
					<view class="mctxt" @click="hidequan">
						确定
					</view>
				</view>
				<scroll-view class="toubox" scroll-y="true">
					<view class="empytView" v-if="!couponList.length">
						<image :src="'/images/kong.png' | formatImgUrl" mode="widthFix" />
						<!-- <view>- 空列表 -</view> -->
					</view>
					<view class="youbg" v-for="item in couponList" @click="selCoupon(item)">
						<image :src="'/images/yh.png' | formatImgUrl" class="youpic" mode=""></image>
						<view class="wenben">
							<view class="youleft">
								<view class="yltop">
									<view class="yline"></view>
									<view class="yltitle">
										<!-- {{item.coupon.title}}券 -->
										{{item.coupon.price}}币<text>约稿红包</text>
									</view>
								</view>
								<view class="mantxt">
									{{item.coupon.des}},满{{item.coupon.man_price}}减{{item.coupon.price}}
								</view>
								<view class="shaotxt oneline">
									有效期至 
									<text>
										{{$options.filters.parseTime(item.validity,'{y}-{m}-{d}') }}
									</text>
								</view>
								
							</view>
							<view class="youtxt" v-if="form.cv_id !==item.id">
								去使用
							</view>
							<view class="youtxt qx" v-else  @tap.stop="coupon_qx(item)">
								取消
							</view>
							
						</view>
					</view>
				</scroll-view>
			</view>
		</u-popup>
		
		
		<uni-popup ref="popup1" maskClick type="bottom">
			<view class="clone_date">
			    <gc-date-picker @change="change1" :dateVal="defaultDate" nowStatus="future" :showSecond="false"></gc-date-picker>
			</view>
		</uni-popup>
		
		<!-- 字数要求弹窗 -->
		<u-popup :show="showFont" mode="bottom" @close="showFont=false">
			<view class="custom-bot">
				<view class="title">
					{{form.task_type == 0 ? '费用标准' : '字数要求'}} 
				</view>
				<picker-view :value="fonts" @change="changeFont" class="picker-view">
					<picker-view-column>
						<view class="item" v-for="(item,index) in fontArr" :key="index">{{item}}</view>
					</picker-view-column>
					<picker-view-column>
						<view class="item" v-for="(item,index) in array" :key="index"><block v-if="form.task_type == 1">每</block>{{item}}</view>
					</picker-view-column>
				</picker-view>
		
				<view class="marginBorder"></view>
				<view class="btn" @tap="showFont=false,form.start_shooting=fontArr[fonts[0]],form.word_count=array[fonts[1]],form.money=form.price*form.start_shooting">
					确认选择
				</view>
			</view>
		</u-popup>
		
		<!-- 费用标准弹窗 -->
		<u-popup :show="showFee" mode="bottom" @close="showFee=false">
			<view class="custom-bot2">
				<view class="title">
					费用标准
				</view>
				<view class="display-flex show-box">
					<view class="inp-box display-flex">
						<input type="text" placeholder="请输入价格" v-model="form.price"/>
						<text>币</text>
					</view>
					<picker-view :value="fees" @change="changeFee" class="picker-view">
						<picker-view-column>
							<view class="item" v-for="(item,index) in array" :key="index">每{{item}}</view>
						</picker-view-column>
					</picker-view>
				</view>
		
				<view class="marginBorder"></view>
				<view class="btn" @tap="showFee=false,form.word_count=array[fees[0]],form.money=form.price*form.start_shooting">
					确认选择
				</view>
			</view>
		</u-popup>
		
		<!-- 性别弹窗 -->
		<u-popup :show="showGender" mode="bottom" @close="showGender=false">
			<view class="custom-bot">
				<view class="title">
					性别要求
				</view>
				<picker-view :value="genders" @change="changeGender" class="picker-view">
					<picker-view-column>
						<view class="item" v-for="(item,index) in array_sex" :key="index">{{item}}</view>
					</picker-view-column>
				</picker-view>
		
				<view class="marginBorder"></view>
				<view class="btn" @tap="showGender=false,form.sex=genders[0]">
					确认选择
				</view>
			</view>
		</u-popup>
		
		<!-- 等级弹窗 -->
		<u-popup :show="showLevel" mode="bottom" @close="showLevel=false">
			<view class="custom-bot">
				<view class="title">
					等级要求
				</view>
				<picker-view :value="levels" @change="changeLevel" class="picker-view">
					<picker-view-column>
						<view class="item" v-for="(item,index) in level_arr" :key="index">{{item}}</view>
					</picker-view-column>
					<picker-view-column>
						<view class="item" v-for="(item,index) in level_arr2" :key="index">{{item}}</view>
					</picker-view-column>
				</picker-view>
		
				<view class="marginBorder"></view>
				<view class="btn" @tap="showLevel=false,form.level=levels">
					确认选择
				</view>
			</view>
		</u-popup>
		
		<!-- 截稿时间 -->
		<u-popup :show="showTime" mode="bottom" @close="showTime=false">
			<view class="custom-bot">
				<view class="title">
					截稿时间
				</view>
				<picker-view :value="times" @change="changeTime" class="picker-view">
					<picker-view-column>
						<view class="item" v-for="(item,index) in years" :key="index">{{item}}</view>
					</picker-view-column>
					<picker-view-column>
						<view class="item" v-for="(item,index) in month" :key="index">{{item}}</view>
					</picker-view-column>
					<picker-view-column>
						<view class="item" v-for="(item,index) in date" :key="index">{{item}}</view>
					</picker-view-column>
					<picker-view-column>
						<view class="item" v-for="(item,index) in hour" :key="index">{{item}}</view>
					</picker-view-column>
					<picker-view-column>
						<view class="item" v-for="(item,index) in minute" :key="index">{{item}}</view>
					</picker-view-column>
				</picker-view>
		
				<view class="marginBorder"></view>
				<view class="btn" @tap="selectTime">
					确认选择
				</view>
			</view>
		</u-popup>
		
		
		<!-- 类型弹窗 -->
		<u-popup :show="showSort" mode="bottom" @close="showSort=false">
			<view class="custom-bot">
				<view class="title">
					类型要求
				</view>
				<picker-view :value="sorts" @change="changeSorts" class="picker-view">
					<picker-view-column>
						<view class="item" v-for="(item,index) in leiList" :key="index">{{item.tit}}</view>
					</picker-view-column>
				</picker-view>
		
				<view class="marginBorder"></view>
				<view class="btn" @tap="showSort=false,lei=sorts[0]">
					确认选择
				</view>
			</view>
		</u-popup>
	</view>
</template>
<script>
	import gcDatePicker from '@/components/gc-date-picker/gc-date-picker.vue'
	import uniPopup from "@/components/uni-popup/uni-popup.vue";
	export default { 
	    components: {
			'gc-date-picker': gcDatePicker,
			uniPopup
		},
		data() {
			return {
				userInfo: this.$db.get('userInfo'),
				// 头像弹框
				show:false,
				show_money:false,
				show_font:false,
				// 标签
				erList:[],
				
				// 生日
				date: new Date().toLocaleDateString().replace(/\//g, "-"),
				array_sex: ['不限', '男', '女'],
				fontArr: [1,2,3,4,5,6,7,8,9],
				array_level: ['不限', '1-10', '11-20','21-30','21-30','31-40','41-50'],
				index: 2,
				paddingBottomHeight: 0, //苹果X以上手机底部适配高度
				number: '',
				info: {},
				isRead: false,
				id:0,
				// 字数
				array: this.$db.get('config').word_count_label,
				// 类型
				leiList:null,
				lei: 0,
				// 起拍
				paiList: '请输入起拍数量',
				// 开关
				value: false,
				// 弹框
				show: false,
				form: {
		
					row_type: 0,
					price: '',
					word_count: this.$db.get('config').word_count_label[2],
					start_shooting: '',
					end_time:"",
					end_time_param: "",
					sex:0,
					level:0,
					money:0,
					cv_id:'',
					coupon_money:'0',
					c_title:"",
					c_desc:"",
					is_primsg:0,
					task_type:0
				},
				his_a:'',
				his_b:this.$db.get('config').word_count_label[2],
				isClick: false,
				couponList:[],
				selCoupItem:{},
				quan: false,
				defaultDate: '', // 默认日期
				showFont: false,
				fonts: [0,0],
				showFee: false,
				fees: [0],
				showGender: false,
				genders: [0],
				level_arr: [],
				level_arr2: ['以上','以内','不限'],
				levels: [0,0],
				showLevel: false,
				month: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
				date: [],
				showTime: false,
				years: [],
				times: [0,new Date().getMonth(),new Date().getDate()-1,0,0],
				hour: [],
				minute: [],
				showSort: false,
				sorts: [0],
				currentType: 0
			}
		},
		onShow() {
			
			console.log("config11")
			if(!this.$db.get('config') || this.$db.get('config') ==null || this.$db.get('config') == undefined){
				console.log("config")
				this.getConfig();
			}
			
			// this.form.c_title = uni.getStorageSync('order_title');
			this.form.c_desc = uni.getStorageSync('order_desc');
			this.getConfig()
			this.get_data();
			
		},
		onLoad(ops) {
			uni.setStorageSync('order_desc',null);
			
			this.getCouponList()
			if(ops.type){
				this.form.task_type = ops.type;
			}
		
			// function prepend(arr, item) {
			//     var newarr = [item];
			//     for(var i = 0; i < arr.length; i++){
			//         newarr.push(arr[i])
			//     }
			//     return newarr
			// }
		
		// 	 let adddata =  {user_name: "超级管理员", class_name: "写手类型", id: "0", name: "不限", heat: 27}
		// 	 let datas = this.$db.get('config').tags.Xslx;
		// 	 var newarr = [adddata];
		// 	    for(var i = 0; i < datas.length; i++){
		// 	        newarr.push(datas[i])
		// 	    }
		
			 // this.leiList = newarr;
		
			 // this.form.end_time_param = this.formateTime()
			 
			 let level = []
			 for (let i = 1; i <= 50; i++) {
			 	level.push(i)
			 }
			 this.level_arr = level
			 
			 let years = []
			 for (let i = 2023; i <= 2123; i++) {
			 	years.push(i)
			 }
			 this.years = years
			 
			 let date = []
			 let days = this.getDays(2023,new Date().getMonth())
			 for (let i = 1; i <= days; i++) {
				 let num = i > 9 ? i : '0' + i
			 	date.push(num)
			 }
			 this.date = date
			 
			 let hour = []
			 for (let i = 0; i <= 59; i++) {
				 let num = i > 9 ? i : '0' + i
			 	hour.push(num)
			 }
			 this.hour = hour
			 this.minute = hour
		},
		methods: {
			selectLevel(){
				this.form.level = this.level_arr[this.levels[0]]
				this.showLevel=false
			},
			// 选择时间
			selectTime(){
				let current = this.years[this.times[0]] + '/' + this.month[this.times[1]] + '/' + this.date[this.times[2]] + ' ' + this.hour[this.times[3]] + ':' + this.minute[this.times[4]]
				
				if(new Date().getTime() > new Date(current).getTime()){
					this.$common.errorToShow('截稿时间不能选择晚于当前时间')
					return
				}
				
				this.showTime=false
				this.confirmTime()
			},
			changeSorts(e){
				this.sorts = e.detail.value
			},
			changeBox(e){
				console.log(e);
				this.isRead = e ? 2 : 0
			},
			getDays(year, month) {
			   let days = [31,28,31,30,31,30,31,31,30,31,30,31] 
			  if ( (year % 4 ===0) && (year % 100 !==0 || year % 400 ===0) ) {
			        days[1] = 29
			  }
			　　return days[month]  
			},
			changeFont(e){
				this.fonts = e.detail.value
			},
			changeFee(e){
				this.fees = e.detail.value
			},
			changeGender(e){
				this.genders = e.detail.value
			},
			changeLevel(e){
				this.levels = e.detail.value
			},
			changeTime(e){
				if(this.times[1] != e.detail.value[1]){
					let date = []
					let days = this.getDays(this.years[e.detail.value[0]],this.month[e.detail.value[1]-1])
					for (let i = 1; i <= days; i++) {
						date.push(i)
					}
					this.date = date
				}
				
				this.times = e.detail.value
				this.form.end_time = this.years[this.times[0]] + '/' + this.month[this.times[1]] + '/' + this.date[this.times[2]] + ' ' + this.hour[this.times[3]] + ':' + this.minute[this.times[4]]  + ':00'
			},
			confirmTime(){
				this.form.end_time = this.years[this.times[0]] + '/' + this.month[this.times[1]] + '/' + this.date[this.times[2]] + ' ' + this.hour[this.times[3]] + ':' + this.minute[this.times[4]]  + ':00'
			},
			change(e) {
				this.form.is_primsg = this.form.is_primsg == 1 ? 0 : 1
			},
			get_data(){
				let that = this;
				this.$api.default.request('user/get_goods_list_type_all', {},'POST',false).then((res) => {
					if (res.code) {
						that.leiList = res.data
					}
				})
			},
			getConfig() {
				this.$api.default.request('Common/getConfig', {},'POST',false).then((res) => {
					if (res.code) {
						this.$db.set('config', res.data)
						
					}
				})
			},
			// 子组件抛出事件
			change1: function(e) {
				this.form.end_time = e
				let dateArr = e.split('/')
				let date = dateArr[2]
				let day = date.split(' ')
				
				this.form.end_time_param = dateArr[0] + '年' + dateArr[1] + '月' + day[0] + '日 ' + day[1];
				console.log('日期选择结果', this.form.end_time)
			},
			// 格式化日期显示
			formateTime: function(val) {
				var date = new Date()
				if (!!val) {
					date = new Date(val.replace(/^\s+|\s+$/g, ''))
				}
				var year = date.getFullYear()
				var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1)
				var day = date.getDate() > 9 ? date.getDate() : '0' + date.getDate()
				var h = date.getHours() > 9 ? date.getHours() : '0' + date.getHours()
				var m = date.getMinutes() > 9 ? date.getMinutes() : '0' + date.getMinutes()
	
				return year + '年' + month + '月' + day + '日 ' + h + ':' + m
			},
			getConfig() {
				console.log(555555555555)
				
				this.$api.default.request('Common/getConfig', {},'POST',false).then((res) => {
					if (res.code) {
						this.$db.set('config', res.data)
						
					}
				})
			},
			open(){
				
			},
			hidequan() {
				this.quan = false
			},
			coupon_qx(){
				this.form.cv_id = ""
				this.form.coupon_money = "0";
				
				this.form.money = this.form.price * this.form.start_shooting
				
				
				this.selCoupItem = {}
				this.quan = false
			},
			selCoupon(item){
				//选需要先设置好价格
				if(this.form.money<=0 ){
					this.$common.errorToShow('需要先设置好价格')
					return;
				}
				
				this.quan = false
				if(parseFloat(this.form.money) >= parseFloat(item.coupon.man_price)){
					this.selCoupItem = item
					this.form.cv_id = item.id
					this.form.coupon_money = item.coupon.price;
					
					if(this.task_type == 0){
						this.form.money = this.form.price * this.form.start_shooting - this.form.coupon_money
					}else{
						this.form.money = this.form.price * this.form.start_shooting - this.form.coupon_money
					}
					
					
					//this.form.coupon_money
				}else{
					this.$common.errorToShow('未满足使用条件')
				}
			},
			getCouponList(){
				this.$api.default.request('user/getCouponList',{type:1},'POST',false).then((res) => {
					if (res.code) {
						this.couponList = res.data
					}
				})
			},
			onInput(e){
				if(e.detail.value < 1){
					this.form.start_shooting = e.detail.value = 1
				}
				
				//this.inputValue = this.inputValue.replace(/[^\d]/g, "");
				this.coupon_qx();
				
				this.form.start_shooting = e.detail.value  = e.detail.value.replace(/[^\d]/g, "");
				// this.form.start_shooting = e
				// this.form.start_shooting = '';
				this.form.money = this.form.price * this.form.start_shooting - this.form.coupon_money
					
				
			},
			openrili(){
				this.$refs.popup1.open();
				// this.$refs.calendar.open();
			},
			confirm(e) {
				console.log(e);
				this.form.end_time = e.fulldate
			},
			setdata(type){
				this.type = type;
				this.show= true;
			},
			postApply() {
				
				if(this.form.task_type==0 && (this.form.price <=0 || this.word_count=='')){
					this.$common.errorToShow('请选择费用标准');
					return;
				}
				
				if( this.form.start_shooting <=0 || this.form.start_shooting == ''){
					this.$common.errorToShow('请输入字数要求');
					return;
				}
				
				if(this.form.c_desc == '' || this.form.c_desc == null){
					this.$common.errorToShow('请输入制作要求');
					return;
				}
				
				if(this.form.end_time == ''){
					this.$common.errorToShow('请选择截稿时间');
					return;
				}
				
				
				if(this.isRead == 2){
					//费用
					
					this.$api.default.request('user/orderpush', this.form, 'POST', false).then((res) => {
						if (res.code) {
							this.$common.successToShow(res.msg, () => {
								uni.navigateBack({//返回上一个页面
									delta: 2
								});
								
								// uni.reLaunch({
								// 	url: '/pages/user/success?id=' + res.data.id
								// })
							})
						}
					})
				}else{
					this.isReadTip()
				}
			},
			isReadTip() {
				if (!this.isRead) {
					this.$common.errorToShow('请先同意用户协议');
					this.isRead = 1
					setTimeout(() => {
						this.isRead = 0;
					}, 300)
					return
				}
			},
			goToxie() {
				uni.navigateTo({
					url: '/pages/webview/webview?url=' + this.$config.default.Url + '/agreement/1000007'
				})
			},
			go_auth(){
				if(this.userInfo.is_auth==1){
					uni.navigateTo({
						url: '/pages/user/auth1'
					})
				}else{
					uni.navigateTo({
						url: '/pages/user/auth'
					})
				}
				
			},
			setting() {
				if(this.his_a <=0){
					this.his_a = 1;
				}
				console.log(777,this.his_a,this.his_b)
				
				if(this.his_a != this.form.price || this.form.word_count != this.his_b){
					// this.form.start_shooting = '';
					
					this.form.price = this.his_a;
					this.form.word_count = this.his_b
					this.form.money = this.form.price * this.form.start_shooting
				}
				this.show = false
			},
			setting1() {
				if(this.his_a <=0){
					this.his_a = 1;
				}
				console.log(777,this.his_a,this.his_b)
				
					this.form.word_count = this.his_b
			
				this.show_font = false
			},
			bindPickerChange_level: function(e) {
					this.form.level = e.detail.value
					
			},
			bindPickerChange_sex: function(e) {
			        
			            // this.index = e.detail.value
						this.form.sex = e.detail.value
						
						    console.log('sex picker发送选择改变，携带值为',this.form.sex)
						// this.saveUser({
						// 	'sex': this.index
						// })
			},
			bindPickerChange: function(e) {
				console.log('picker1111111发送选择改变，携带值为', e.detail.value)
				this.index = e.detail.value
				// this.form.word_count = this.array[e.detail.value]
				this.his_b = this.array[e.detail.value]
			},
			getUserInfo() {
				this.$api.default.request('user/userInfo').then((res) => {
					if (res.code) {
						this.userInfo = res.user
						this.index = res.user.sex?res.user.sex:0
					} else {
						this.$common.errorToShow(res.msg)
					}
				})
			},
			onChooseAvatar(e) {
				this.$common.uploadImg(e.detail.avatarUrl, (data) => {
					if (data) {
						this.saveUser({
							'pic': data
						})
					}
				})
			},
			bindNick(e) {
				console.log(e)
				if (e.detail.value != this.userInfo.username) {
					this.userInfo.username = e.detail.value
					this.saveUser({
						'username': this.userInfo.username
					})
				}
			},
			saveUser(data) {
				this.$api.default.request('user/saveUser', data).then((res) => {
					if (res.code == 1) {
						this.userInfo = res.user
						this.$common.successToShow(res.msg)
					} else {
						this.$common.errorToShow(res.msg)
					}
				})
			},
			
			close() {
				this.show = false
			},
			// 生日
			 bindDateChange: function(e) {
				this.date = e.detail.value
				this.saveUser({
					'birthday': e.detail.value
				})
			},
			
			// 类型
			leiChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.detail.value)
				this.lei = e.detail.value
				this.form.row_type = this.leiList[e.detail.value].id
			}
		}
	}
</script>

<style lang="scss">
	
	.custom-bot {
		text-align: center;
		background-color: #fff;
		
		.title{
			padding: 20px 0;
			font-family: '思源黑体';
			font-size: 14px;
			font-weight: bold;
			color: #3D3D3D;
		}
	
		.picker-view {
			width: 750rpx;
			height: 200rpx;
		}
	
		.item {
			height: 34px;
			line-height: 34px;
			font-family: '思源黑体';
			font-size: 15px;
			font-weight: bold;
			color: #3D3D3D;
		}
		
		.marginBorder{
			width: 100%;
			height: 10px;
			background: #F2F5F2;
		}
		
		.btn{
			margin: 10px auto;
			width: 315px;
			height: 40px;
			line-height: 40px;
			border-radius: 8px;
			background: #45C4B0;
			font-family: '思源黑体';
			font-size: 16px;
			font-weight: bold;
			color: #FFFFFF;
		}
	}
	
	.custom-bot2 {
		background-color: #FFFFFF;
		width: 750rpx;
		border-radius: 10px;
		text-align: center;
		
		.title{
			padding: 20px 0;
			font-family: '思源黑体';
			font-size: 14px;
			font-weight: bold;
			color: #3D3D3D;
		}
		
		.show-box{
			justify-content: center;
		}
	
		.picker-view {
			margin-left: 75rpx;
			width: 100rpx;
			height: 200rpx;
		}
		
		.inp-box{
			height: 34px;
			line-height: 34px;
			width: 200rpx;
			margin-right: 25rpx;
			border-top: 1px solid #eee;
			border-bottom: 1px solid #eee;
			color: #3D3D3D;
			font-family: '思源黑体';
			font-weight: bold;
			
			text{
				font-size: 15px;
			}
		}
		
		input{
			height: 34px;
			line-height: 34px;
			font-size: 15px;
		}
	
		.item {
			height: 34px;
			line-height: 34px;
			font-family: '思源黑体';
			font-size: 15px;
			font-weight: bold;
			color: #3D3D3D;
		}
		
		.marginBorder{
			width: 100%;
			height: 10px;
			background: #F2F5F2;
		}
		
		.btn{
			margin: 10px auto;
			width: 80%;
			height: 40px;
			line-height: 40px;
			border-radius: 8px;
			background: #45C4B0;
			font-family: '思源黑体';
			font-size: 16px;
			font-weight: bold;
			color: #FFFFFF;
		}
	}
	
	page {
		background: rgba(242, 245, 242, 1);
	}
	.order_push{
	.numtxt {
		font-size: 28rpx;
		font-weight: normal;
		letter-spacing: 0em;
		color: #999999;
		
		text{
			color: #45C4B0;
			padding-left: 10rpx;
		}
	}
	.clone_date{
		background: #fff;
		width: 100%;
		height: 350rpx;;
	}
	
		width: 100%;
		.dibox {
			// z-index: 10;
			position: fixed;
			bottom: 0;
			left: 0;
			width: 100%;
			background-color: #ffffff;
			padding: 20rpx 66rpx 20rpx 54rpx;
			box-sizing: border-box;
		
			.zaibox {
				width: 630rpx;
				height: 80rpx;
				border-radius: 12px;
				background: #3D3D3D;
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin: 0 auto 10rpx;
		
				.zaileft {
					padding: 0 20rpx;
		
					.dbox {
						display: flex;
						align-items: center;
		
						.zaititle {
							margin-left: 5px;
							font-size: 28rpx;
							font-weight: bold;
							background: linear-gradient(293deg, #45C4B0 -5%, #56E8B5 128%);
							-webkit-background-clip: text;
							-webkit-text-fill-color: transparent;
							background-clip: text;
							text-fill-color: transparent;
		
						}
		
						.text {
							font-size: 28rpx;
							font-weight: bold;
							color: #FFFFFF;
							padding-left: 8rpx;
						}
					}
		
					.zaitxt {
						font-size: 20rpx;
						font-weight: normal;
						letter-spacing: 0px;
						color: #999999;
					}
				}
		
				.que {
					width: 190rpx;
					height: 80rpx;
					border-radius: 10px;
					opacity: 1;
					background: #45C4B0;
					font-size: 24rpx;
					font-weight: bold;
					color: #FFFFFF;
					text-align: center;
					line-height: 80rpx;
				}
				
				.que2 {
					width: 190rpx;
					height: 80rpx;
					border-radius: 10px;
					opacity: 1;
					background: #999;
					font-size: 24rpx;
					font-weight: bold;
					color: #FFFFFF;
					text-align: center;
					line-height: 80rpx;
				}
			}
		
			.xiebox {
				display: flex;
				align-items: center;
				justify-content: center;
				padding-bottom: 10rpx;
		
				.xietxt {
					font-size: 20rpx;
					font-weight: bold;
					color: #999999;
		
					text {
						font-size: 20rpx;
						font-weight: bold;
						color: #45C4B0;
						padding: 0 10rpx;
					}
				}
			}
		}
		
		
	
	.mask111 {
		background: #F2F5F2;
		border-top-left-radius: 8px;
		border-top-right-radius: 8px;
		overflow: hidden;
	
		.matop {
			padding: 0 30rpx;
			height: 120rpx;
			opacity: 1;
			background: #FFFFFF;
			display: flex;
			align-items: center;
			justify-content: space-between;
	
			.matxt {
				font-size: 30rpx;
				color: #999999;
			}
	
			.matitle {
				font-size: 36rpx;
				font-weight: bold;
				color: #3D3D3D;
			}
	
			.mctxt {
				font-size: 30rpx;
				color: #3D3D3D;
			}
		}
	
		.cabox {
			max-height: 600rpx;
			padding: 20rpx 30rpx;
	
			.cali {
				margin-bottom: 20rpx;
				width: 650rpx;
				height: 172rpx;
				padding: 0 20rpx;
				border: 1px solid #ffffff;
				background-color: #ffffff;
				border-radius: 10px;
				position: relative;
	
				.san {
					position: absolute;
					bottom: 0;
					right: 0;
					width: 60rpx;
					height: 60rpx;
					z-index: 10;
				}
	
				.dui {
					position: absolute;
					right: 2rpx;
					bottom: 2rpx;
					width: 32rpx;
					height: 32rpx;
					z-index: 22;
				}
	
				.catop {
					display: flex;
					align-items: center;
					padding-bottom: 12rpx;
					padding-top: 22rpx;
	
					.cpic {
						width: 32rpx;
						height: 32rpx;
						flex-shrink: 0;
					}
	
					.catitle {
						font-size: 28rpx;
						font-weight: bold;
						color: #3D3D3D;
						padding-left: 8rpx;
					}
				}
	
				.zhitxt {
					font-size: 20rpx;
					color: #3D3D3D;
					padding-bottom: 6rpx;
	
					text {
						padding-left: 8rpx;
						font-size: 20rpx;
						color: #999999;
					}
				}
	
				.jiage {
					font-size: 36rpx;
					font-weight: bold;
					color: #45C4B0;
	
					text {
						font-weight: 500;
						font-size: 20rpx;
						color: #999999;
						padding-left: 5rpx;
					}
				}
			}
	
			.active {
				border: 1px solid #45C4B0;
			}
		}
	
		.toubox {
			max-height: 680rpx;
			padding: 20rpx 30rpx;
	
			.youbg {
				width: 690rpx;
				height: 220rpx;
				margin-bottom: 20rpx;
				position: relative;
	
				.youpic {
					width: 100%;
					height: 215rpx;
				}
	
				.wenben {
					position: absolute;
					left: 0;
					top: 0;
					width: 100%;
					height: 215rpx;
					display: flex;
					align-items: flex-start;
					justify-content: space-between;
	
					.youleft {
						width: 90%;
						// padding-left: 20rpx;
						margin-left: 5%;
						flex-shrink: 0;
	
						.yltop {
							
							display: flex;
							align-items: center;
							height: 98rpx;
							border-bottom: 1px dashed #D8D8D8;
	
							.yline {
								width: 4rpx;
								height: 42rpx;
								border-radius: 84px;
								opacity: 1;
								background: #45C4B0;
							}
	
							.yltitle {
								font-size: 45rpx;
								font-weight: 500;
								color: #3D3D3D;
								padding-left: 12rpx;
								text{
									color: #45C4B0;
								}
							}
						}
	
						.mantxt {
							color: #999999;
							margin-top: 8px;
							font-size: 13px;
							font-weight: 500;
						}
	
						.shaotxt {
							font-size: 24rpx;
							font-weight: 300;
							color: #999999;
							margin-top: 5px;
							text{
								margin-left: 5px;
							}
						}
					}
	
					.youtxt {
						font-size: 12px;
						position: absolute;
						right: 10px;
						top:71px;
						width: 60px;
						height: 16px;
						border-radius: 146px;
						opacity: 1;
						/* 自动布局 */
						display: flex;
						flex-direction: column;
						padding: 3px 12px;
						text-align: center;
						border: 1px solid #45C4B0;
						color: #45C4B0;
					}
					.qx{
						color: #999999;
						border: 1px solid #999;
					}
				}
			}
		}
	}
		.mask1 {
			background-color: #FFFFFF;
			width: 500rpx;
			border-radius: 10px;
			padding: 30rpx;
		
			.jatitle {
				font-size: 28rpx;
				font-weight: bold;
				padding-bottom: 20rpx;
			}
		
			.japut {
				border-bottom: 1px solid #f2f2f2;
				font-size: 24rpx;
				color: #3D3D3D;
				padding-bottom: 15rpx;
				margin-bottom: 30rpx;
			}
		
			.qubox {
				display: flex;
				align-items: center;
				justify-content: space-between;
		
				.quli {
					border-radius: 8px;
					border: 1px solid #eeeeee;
					font-size: 24rpx;
					color: #999999;
					width: 220rpx;
					text-align: center;
					height: 60rpx;
					line-height: 60rpx;
				}
		
				.que {
					border-radius: 8px;
					border: 1px solid #45C4B0;
					background-color: #45C4B0;
					font-size: 24rpx;
					color: #ffffff;
					text-align: center;
					width: 220rpx;
					height: 60rpx;
					line-height: 60rpx;
				}
			}
		}
	
	
	}
	.order_push_top {
		
		padding-top: 20rpx;
		width: 92%;
		margin-left:4%;
		.baibox{
			border-radius: 0.5em;
			background-color: #ffffff;
			padding: 0 30rpx;
			margin-bottom: 20rpx;
			.baiput{
				
				width: 100%;
				height: 120rpx;
				border-bottom: 1px solid rgba(153, 153, 153, 0.1);
				font-size: 24rpx;
				font-weight: normal;
				letter-spacing: 0em;
				color: #3D3D3D;
				// line-height: 174rpx;
				.title {
					font-size: 28rpx;
					font-weight: bold;
					letter-spacing: 0em;
					color: #3D3D3D;
					line-height: 36px !important;
					left: 120;
				}
				.rarrs {
					width: 40rpx;
					height: 40rpx;
					position: relative;
					top: 0px;
					right: 0px;
				}
				
			}
			.baili:last-child{
				border: none;
			}
			.baili{
				display: flex;
				align-items: center;
				justify-content: space-between;
				min-height: 120rpx;
				border-bottom: 1px solid rgba(153, 153, 153, 0.1);
				
				.zhan {
					font-size: 28rpx;
					font-weight: bold;
					letter-spacing: 0em;
					color: #3D3D3D;
					.bnt{
						color: #999;
						font-size: 11px;
						font-weight: 500;
						span{
							color: #45C4B0;
						}
					}	
				}
				
				.txt{
					flex-grow: 1;
					font-size: 28rpx;
					font-weight: bold;
					letter-spacing: 0em;
					color: #3D3D3D;
					flex-shrink: 0;
				}
				
				.left {
					flex-shrink: 0;
				
					.title {
						font-size: 28rpx;
						font-weight: bold;
						letter-spacing: 0em;
						color: #3D3D3D;
						padding-bottom: 10rpx;
					}
				
					.txt {
						font-size: 24rpx;
						font-weight: normal;
						letter-spacing: 0em;
						color: #3D3D3D;
					}
				
					.put {
						width: 500rpx;
						font-size: 24rpx;
						font-weight: normal;
						letter-spacing: 0em;
						color: #3D3D3D;
					}
				}
				.cenbox{
					flex-grow: 1;
					font-size: 27rpx;
					color: #999;
					display: flex;
					align-items: center;
					justify-content: flex-end;
					padding: 0 16rpx;
					
					overflow: hidden; //超出隐藏
					white-space: nowrap; //不换行，同一行展示
					text-overflow: ellipsis; //设置超出部分以省略号展示
					.headpic{
						width: 80rpx;
						height: 80rpx;
						border-radius: 50%;
					}
					.c_desc{
						width: 60%;
						text-align: right;
					}
					.centxt{
						font-size: 27rpx;
						font-weight: normal;
						text-align: right;
						letter-spacing: 0em;
						color: #999999;
						width: 440rpx;
						.tp1{
							font-size: 16px;
							color: #45C4B0;
							font-weight: 700;
						}
						.tp2{
							margin-left: 5px;
							font-size: 11px;
							color: #999;
						}
						
					}
					.is_auth{
						color:#45C4B0;
					}
					.is_no_auth{
						color:#999;
					}
					.qianbox{
						text-align: right;
						width: 450rpx;
						white-space: nowrap;
						.qli{
							background: rgba(153, 153, 153, 0.1);
							padding: 3rpx 12rpx 4rpx 8rpx;
							border-radius: 178px;
							font-size: 24rpx;
							color: #3D3D3D;
							display: inline-block;
						}
						.qli:not(:first-child){
							margin-left: 16rpx;
						}
					}
				}
				.rarr{
					width: 40rpx;
					height: 40rpx;
					flex-shrink: 0;
				}
				.desText {
					display: flex;
					justify-content: center;
					align-items: flex-end;
					height: 80rpx;
					font-size: 24rpx;
					color: #45C4B0;
				}
				
			}
		}
	
		
		// .mask1 {
		// 		background-color: #FFFFFF;
		// 		width: 500rpx;
		// 		border-radius: 10px;
		// 		padding: 30rpx;
			
		// 		.jatitle {
		// 			font-size: 28rpx;
		// 			font-weight: bold;
		// 			padding-bottom: 20rpx;
		// 		}
			
		// 		.japut {
		// 			border-bottom: 1px solid #f2f2f2;
		// 			font-size: 24rpx;
		// 			color: #3D3D3D;
		// 			padding-bottom: 15rpx;
		// 			margin-bottom: 30rpx;
		// 		}
			
		// 		.qubox {
		// 			display: flex;
		// 			align-items: center;
		// 			justify-content: space-between;
			
		// 			.quli {
		// 				border-radius: 8px;
		// 				border: 1px solid #eeeeee;
		// 				font-size: 24rpx;
		// 				color: #999999;
		// 				width: 220rpx;
		// 				text-align: center;
		// 				height: 60rpx;
		// 				line-height: 60rpx;
		// 			}
			
		// 			.que {
		// 				border-radius: 8px;
		// 				border: 1px solid #45C4B0;
		// 				background-color: #45C4B0;
		// 				font-size: 24rpx;
		// 				color: #ffffff;
		// 				text-align: center;
		// 				width: 220rpx;
		// 				height: 60rpx;
		// 				line-height: 60rpx;
		// 			}
		// 		}
		// 	}
		
	}
	
	.bnt{
		color: #999;
		font-size: 11px;
		font-weight: 500;
		span{
			color: #45C4B0;
		}
	}	
	
	.xubox {
		padding: 0 30rpx;
	
		.xutxt {
			font-size: 20rpx;
			line-height: 37rpx;
			font-weight: normal;
			letter-spacing: 0em;
			color: #999999;
		}
	}
</style>